package carassius.GUI;

import java.awt.Component;
import javax.swing.AbstractCellEditor;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author siebz0r
 */
public class DoubleTableCellEditor
		extends AbstractCellEditor
		implements TableCellEditor
{
	private final DoubleTextField DOUBLE_TEXT_FIELD;

	public DoubleTableCellEditor()
	{
		DOUBLE_TEXT_FIELD = new DoubleTextField();
	}

	@Override
	public Object getCellEditorValue()
	{
		return DOUBLE_TEXT_FIELD.getValue();
	}

	@Override
	public Component getTableCellEditorComponent(JTable table, Object value,
												 boolean isSelected, int row,
												 int column)
	{
		DOUBLE_TEXT_FIELD.setValue((Double) value);
		return DOUBLE_TEXT_FIELD;
	}

	public boolean isValueValid()
	{
		return DOUBLE_TEXT_FIELD.textIsValid();
	}
}
